package vn.gq.udv.comic;

import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.widget.Toast;

import com.actionbarsherlock.app.SherlockFragmentActivity;

public class BaseActivity extends SherlockFragmentActivity {

	public static final String PREF_BOOKMARK = "pref_bookmark";
	
	public Handler mHandler;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		mHandler = new Handler();
		super.onCreate(savedInstanceState);
	}
	
	
	public void showDialogExit() {
		AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this);
		builder.setMessage("Hãy dành chút thời gian đánh giá cho ứng dụng!")
		.setCancelable(true)
		.setTitle("TOIYEUMOBILE")
		.setIcon(android.R.drawable.btn_star_big_on)
		.setPositiveButton("Đánh giá", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				try {
					startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+getPackageName())));
				} catch(ActivityNotFoundException e) {
					Toast.makeText(BaseActivity.this, "Ứng dụng Google Play không được cài trên máy", Toast.LENGTH_SHORT).show();
				}
			}
		})
		.setNegativeButton("Thoát", new DialogInterface.OnClickListener() {
			@SuppressWarnings("deprecation")
			@Override
			public void onClick(DialogInterface dialog, int which) {
				onDestroy();
				System.runFinalizersOnExit(true);
				System.exit(0);
			}
		});
		AlertDialog alertDialog = builder.create();
		alertDialog.show();
	}
}
